<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let arr = new Array(1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4);
        /* 数组去重 */
        Array.prototype.norepeat = function(){
            /* 
                第一种方法:
            */
            let newArr = [];
            //如果newArr当中不存在 this[i] 元素,那么往里面扔
            for(let i = 0 ; i < this.length ; i++){
                // if(newArr.indexOf(this[i]) == -1){
                //     newArr.push(this[i])
                // }


                if(!newArr.includes(this[i])){
                    newArr.push(this[i])
                }
            }
            // console.log(newArr);
            return newArr;
        }
        let result = arr.norepeat();
        console.log(result);
    </script>
</body>

</html>